<?
session_start(); 
include("./includes/functions.php");
date_default_timezone_set('Asia/Saigon');

if(isset($_COOKIE['ad_username']) && $_COOKIE['ad_username'] != '')
{
	if(isset($_COOKIE['login']) && $_COOKIE['login'] != '' ||(isset($_SESSION['slogin']) && $_SESSION['slogin'] == '1') )
	{
		//echo $_COOKIE['login'];
		if(isset($_COOKIE['login']) && $_COOKIE['login']== 1)
		{
			//setcookie('login', '1', time()- 500);
			$_SESSION['slogin'] = '1';		
		}
		define('TPL_DIR','templates/site/');
		define('SRC_DIR','sources/site/');
		define('CLASS_DIR','class/');
		
		
		//include("./includes/functions.php");
		include("./includes/va_db.php");
		include("./includes/config.php");
		include("./includes/constant.php");
		include("./class/categories.class.php");
		include("./kam/admin/function.php");
		
		include(CLASS_DIR.'bao_tri.class.php');
		include(CLASS_DIR."info.class.php");
		include(CLASS_DIR."yahoo.class.php");
		include(CLASS_DIR."skype.class.php");
		include(CLASS_DIR."template.php");
		include(CLASS_DIR."cart.class.php");
		include("ckeditor_config.php");
		$CKEditor->config['width'] = 600;
		$CKEditor->config['height'] = 300;
		
		$do   = isset($_GET["do"])  ? $_GET["do"] :'main';
		$act   = isset($_GET["act"])  ? $_GET["act"]  : "";
		$page   = isset($_GET["page"])  ? $_GET["page"]  : '1';//for paging
		
		$file_php = "./kam/modules/".$do."/admin/$do.php";
		if (!file_exists($file_php)){
			$msg="There is not this function!!!";
			$p='./123.php';
		
			page_transfer($msg,$p);
		}
		else{
			require($file_php);
		}
		setcookie('login', $_COOKIE['login'], time()+ 500);
		setcookie('ad_id', $_COOKIE['ad_id'], time()+ 500);
		setcookie('ad_username', $_COOKIE['ad_username'], time()+ 500);
		setcookie('ad_group', $_COOKIE['ad_group'], time()+ 500);
		include("./kam/admin/admin-pro.php");
	}
	else
	{
		$page = "./login-admin.html";
		$msg = "Bạn Vui Lòng Đăng Nhập";
		page_transfer_admin($msg,$page);
	}
}
else
{
	$page = "./login-admin.html";
	$msg = "Bạn Vui Lòng Đăng Nhập";
	page_transfer_admin($msg,$page);
}
?>
